package com.qfedu.mbti.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qfedu.mbti.dto.ExamQuestion;
import com.qfedu.mbti.entity.MbtiQuestion;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * mbti测试题表(MbtiQuestion)表数据库访问层
 *
 * @author makejava
 * @since 2024-11-04 11:43:41
 */
public interface MbtiQuestionDao extends BaseMapper<MbtiQuestion> {

    @Select("select * from t_mbti_question order by rand() limit 4)")
    List<MbtiQuestion> selectRandom();

    //多表联查 查询用户的测试题
    @Select("select mq.*,me.title from t_mbti_exam me inner join t_mbti_question mq on me.id=mq.meid where me.uid=#{uid} order by mq.create_time desc")
    List<ExamQuestion> selectByUid(Integer uid);
}

